<template>
    <tpl src="res/tpl/components/dialog.tpl" width="420" height="350" title="背包" :visible="visible">
        <img #for="5" #key="k" #value="v" src="res/ui/colorLight.png" color="#634d31" width="400" x="10" :y="90+k*50"></img>
        <img #for="7" #key="k" src="res/ui/colorLight.png" color="#634d31" height="245" :x="60+k*50" y="45"></img>
        <img src="res/ui/iconGold.png" x="30" y="295"></img>
        <img src="res/ui/ground3.png" x="80" y="300" width="180" height="30" grid="[7,7,7,7]">
            <txt text="888,888,888" x="8" y="5" size="16" color="#ffffff"></txt>
        </img>
        <tpl src="res/tpl/components/button.tpl" icon="res/ui/btnBlue.png" title="回收" x="280" y="300" width="80" height="32" grid="[16,16,16,16]" @click="test"></tpl>
        <img #for="items" #key="k" #value="v" @over="tipOn($event, k)" @out="tipOut" #if="k>0 && bagTitle==''" :src="v.img" width="40" height="40" :x="15+k*50" y="45"></img>
    </tpl>
</template>

<script>
init(){
    this.bagTitle= "";
    this.items1= {
        a: {name: "100元宝", img: "res/ui/iconMoney.png", desc: "使用后可获得100元宝"},
        b: {name: "裁决之杖", img: "res/item/weapon.png", desc: "攻击: 100 - 3000\n幸运: +9\n等级: 30"},
        c: {name: "200元宝", img: "res/ui/iconMoney.png", desc: "使用后可获得200元宝"},
        d: {name: "300元宝", img: "res/ui/iconMoney.png", desc: "使用后可获得300元宝"},
        e: {name: "元宝大礼包长长长长长长长长长长长长", img: "res/ui/iconMoney.png", desc: "使用后可获得100元宝"}
    };
    this.items= [
        {name: "100元宝", img: "res/ui/iconMoney.png", desc: "使用后可获得100元宝"},
        {name: "裁决之杖", img: "res/item/weapon.png", desc: "攻击: 100 - 3000\n幸运: +9\n等级: 30"},
        {name: "200元宝", img: "res/ui/iconMoney.png", desc: "使用后可获得200元宝"},
        {name: "300元宝", img: "res/ui/iconMoney.png", desc: "使用后可获得300元宝"},
        {name: "元宝大礼包长长长长长长长长长长长长", img: "res/ui/iconMoney.png", desc: "使用后可获得100元宝"}
    ];
}

create() {
    console.log("bag create");
}

update(delta) {

}

destroyed() {
    
}

test(event){
    console.log("回收",event);
}

tipOn(event, itemIndex){
    this.tipX = TIP.x = event.x + 1;
    this.tipY = TIP.y = event.y + 1;
    TIP.updateContent(this.items[itemIndex].name, this.items[itemIndex].desc);
    TIP.visible = true;
}

tipOut(event){
    TIP.visible = false;
}

</script>